package com.easyto.order.fallbackfactory;

import com.easyto.order.apis.PayFeignApi;
import com.easyto.order.response.UserDTO;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;


@Component
public class MyFallbackFactory implements FallbackFactory<PayFeignApi> {

    @Override
    public PayFeignApi create(Throwable cause) {
        return new PayFeignApi() {
            @Override
            public String getPayApi() {
                return null;
            }

            @Override
            public UserDTO queryUserById(String uId) {

                // 服务降级的处理逻辑，比如返回一个默认值或执行备选逻辑

                System.out.println(">>>>>>>>>>>>>>>>> 进入降级了 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ");

                return new UserDTO("99999999999", "fallback response", "fallback response");
            }

        };
    }
}
